﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using HybridLab.Workflow.Activities.Info;
using HybridLab.Virtual.Interfaces;
using Microsoft.TeamFoundation.Build.Client;

namespace HybridLab.Workflow.Activities.CodeActivities
{
	[BuildActivity(HostEnvironmentOption.All)]
	public sealed class GetHybridLabVirtualHost : CodeActivity<IVirtualHost>
	{
		public InArgument<HybridLabEnvironment> HybridLabEnvironment { get; set; }

		protected override IVirtualHost Execute(CodeActivityContext context)
		{
			var environment = context.GetValue(HybridLabEnvironment);

			var lab = VirtualHostCatalog.GetHost(environment.HostType, environment.HostName, environment.Credentials.DomainName, environment.Credentials.UserName, environment.Credentials.Password);
			context.LogMessage("Connected to host {0} ({1})", environment.HostName, environment.HostType);
			return lab;
		}
	}
}
